import request from '@/utils/request'

// 正向追溯 - 根据原料批次追溯到成品
export function forwardTrace(batchCode) {
  return request({
    url: '/mes/traceability/forward/' + batchCode,
    method: 'get'
  })
}

// 反向追溯 - 根据成品追溯到原料
export function reverseTrace(productId) {
  return request({
    url: '/mes/traceability/reverse/' + productId,
    method: 'get'
  })
}

// 根据工单ID获取完整追溯信息
export function getTraceByWorkOrder(workOrderId) {
  return request({
    url: '/mes/traceability/workOrder/' + workOrderId,
    method: 'get'
  })
}

// 追溯分析 - 获取追溯统计信息
export function getTraceAnalysis(params) {
  return request({
    url: '/mes/traceability/analysis',
    method: 'get',
    params: params
  })
}

// 生成追溯报告
export function generateReport(data) {
  return request({
    url: '/mes/traceability/report',
    method: 'post',
    data: data
  })
}

// 获取追溯树结构数据
export function getTraceTree(traceId) {
  return request({
    url: '/mes/traceability/tree/' + traceId,
    method: 'get'
  })
}